package mediator.chat;

public abstract class UserColleague {

	AbstChatMediator mediator = null;

	String name;

	public UserColleague(AbstChatMediator mediator, String name) {
		this.mediator = mediator;
		this.name = name;
	}

	/** 群发 */
	abstract void sendToAll(String msg);

	/** 发给某人 */
	abstract void sendToPerson(String msg, String name);

	/** 接收消息 */
	abstract void accept(String msg);

	/** 加入聊天室 */
	abstract void join();

	/** 离开聊天室 */
	abstract void leave();
}

class ConcreteColleague extends UserColleague {

	public ConcreteColleague(AbstChatMediator mediator, String name) {
		super(mediator, name);
	}

	@Override
	void sendToAll(String msg) {
		this.mediator.sendToAll(msg);
	}

	@Override
	void sendToPerson(String msg, String name) {
		this.mediator.sendToPerson(msg, name);
	}

	@Override
	void accept(String msg) {
		System.out.println(this.name + "收到消息:" + msg);
	}

	@Override
	void join() {
		this.mediator.join(this);
	}

	@Override
	void leave() {
		this.mediator.leave(this);
	}

}
